[PR]

水無瀬の部屋 > Programming > sample > tools > header > toolbase.h
最終更新日: 2007/04/03

   1: //*********************************************************
   2: // プロジェクト: TOOLS
   3: //  ファイル名: toolbase.h
   4: //*********************************************************
   5: #ifndef TOOLBASE_HEAD_INCLUDED // 多重インクルードの防止
   6: #define TOOLBASE_HEAD_INCLUDED
   7: 
   8: 
   9: //*********************************************************
  10: // コンパイル環境の指定
  11: //*********************************************************
  12: #ifndef PRIVATE_TOOLS_HEAD_INCLUDED // 冗長ガード
  13: #include <header/_tools.h>
  14: #ifndef PRIVATE_TOOLS_HEAD_INCLUDED // ガード名の検査
  15: #error "? PRIVATE_TOOLS_HEAD_INCLUDED"
  16: #endif // #ifndef PRIVATE_TOOLS_HEAD_INCLUDED
  17: #endif // #ifndef PRIVATE_TOOLS_HEAD_INCLUDED
  18: 
  19: 
  20: //*********************************************************
  21: // マクロ の 定義
  22: //*********************************************************
  23: // [仮] パスの最大長
  24: #define MAX_PATH_BUF  ( 2 * (1 + MAX_PATH) )
  25: 
  26: // 長さ不明のパスを格納するのに十分(?)な領域を指定しているか
  27: #define IsEnoughPathBufferSize( bufsize )  ( MAX_PATH <= (bufsize) )
  28: 
  29: //
  30: #define IsGregory(year,month,day)  (((year)>1582)||(((year)==1582)&&(((month)>10)||(((month)==10)&&((day)>=15)))))
  31: 
  32: // ビット操作
  33: #define BIT(a)                  (1 << (a))   //
  34: #define BIT_ON(a,b)    ( (a) |  (1 << (b)) ) //
  35: #define BIT_OFF(a,b)   ( (a) & ~(1 << (b)) ) //
  36: 
  37: //
  38: #define IsAlpha(c)  (isalpha(  static_cast<UCHAR>(c) ))
  39: #define IsUpper(c)  (isupper(  static_cast<UCHAR>(c) ))
  40: #define IsLower(c)  (islower(  static_cast<UCHAR>(c) ))
  41: #define IsDigit(c)  (isdigit(  static_cast<UCHAR>(c) ))
  42: #define IsXdigit(c) (isxdigit( static_cast<UCHAR>(c) ))
  43: #define IsSpace(c)  (isspace(  static_cast<UCHAR>(c) ))
  44: #define IsPunct(c)  (ispunct(  static_cast<UCHAR>(c) ))
  45: #define IsAlnum(c)  (isalnum(  static_cast<UCHAR>(c) ))
  46: #define IsPrint(c)  (isprint(  static_cast<UCHAR>(c) ))
  47: #define IsGraph(c)  (isgraph(  static_cast<UCHAR>(c) ))
  48: #define IsCntrl(c)  (iscntrl(  static_cast<UCHAR>(c) ))
  49: #define ToUpper(c)  (toupper(  static_cast<UCHAR>(c) ))
  50: #define ToLower(c)  (tolower(  static_cast<UCHAR>(c) ))
  51: 
  52: // 2バイト文字
  53: #define MAKEDBC(lead,trail)  (static_cast<unsigned short>((static_cast<unsigned char>(lead) << 8) | static_cast<unsigned char>(trail)))
  54: #define jis1(c)              ((0x21 <= static_cast<unsigned char>(c)) && (static_cast<unsigned char>(c) <= 0x7E))
  55: #define jis2(c)              ((0x21 <= static_cast<unsigned char>(c)) && (static_cast<unsigned char>(c) <= 0x7E))
  56: #define jms1(c)              (((0x81 <= static_cast<unsigned char>(c)) && (static_cast<unsigned char>(c) <= 0x9F)) || ((0xE0 <= static_cast<unsigned char>(c)) && (static_cast<unsigned char>(c) <= 0xFC)))
  57: #define jms2(c)              ((0x7F != static_cast<unsigned char>(c)) && (0x40 <= static_cast<unsigned char>(c)) && (static_cast<unsigned char>(c) <= 0xFC))
  58: #define euc1(c)              ((0x8E == static_cast<unsigned char>(c)) || ((0xA1 <= static_cast<unsigned char>(c)) && (static_cast<unsigned char>(c) <= 0xFE)))
  59: #define euc2(c)              ((0xA1 <= static_cast<unsigned char>(c)) && (static_cast<unsigned char>(c) <= 0xFE))
  60: #define is_jis(jis)          ((jis1(HIBYTE((jis))) && jis2(LOBYTE((jis)))) || ((0x00A1 <= (jis)) && ((jis) <= 0x00DF)))
  61: #define is_jms(jms)          ( jms1(HIBYTE((jms))) && jms2(LOBYTE((jms))) )
  62: #define is_euc(euc)          ( euc1(HIBYTE((euc))) && euc2(LOBYTE((euc))) )
  63: 
  64: 
  65: //*********************************************************
  66: // 関数 の 宣言
  67: //*********************************************************
  68: #ifdef __cplusplus
  69: extern "C" {
  70: #endif
  71: 
  72: 
  73: // toolbase.cpp
  74: // a
  75: // b
  76: int     bitcount( BYTE b );
  77: int     bitcount8( BYTE b8 );
  78: int     bitcount16( WORD w16 );
  79: int     bitcount32( DWORD dw32 );
  80: int     bitcount64( DWORD64 dw64 );
  81: void    bool_inverse( bool *bValue );
  82: 
  83: // c
  84: //int    chrcmp( int c1, int c2 );
  85: //int    chrcmpi( int c1, int c2 );
  86: bool    chreql( int c1, int c2 );
  87: bool    chreqli( int c1, int c2 );
  88: char   *CutFileExtension( char *path );
  89: char   *CutFileName( char *path );
  90: 
  91: // d
  92: // e
  93: // f
  94: bool    fgetsz( char *buffer, int bufsize, FILE *fp );
  95: void    fputeuc( int euc, FILE *fp );
  96: void    fputf( FILE *fw, FILE *fr );
  97: void    fputjms( int jms, FILE *fp );
  98: bool    fputsz( const char *string, FILE *fp );
  99: 
 100: // g
 101: int     GetDayOfWeek( int year, int month, int day );
 102: char   *GetFileExtensionPtr( const char *path );
 103: bool    GetFileLocation( const char *path, char *buf, size_t bufsize );
 104: char   *GetFileNamePtr( const char *path );
 105: int     GetMonthDays( int year, int month );
 106: 
 107: // h
 108: // i
 109: bool    IsBackslash( const char *str, size_t pos );
 110: int     isJMS( const char *s, size_t pos );
 111: bool    IsLeapYear( int year );
 112: bool    IsPathDescendant( const char *descendant, const char *ancestor );
 113: bool    IsPathTailSeparator( const char *path );
 114: bool    IsSortedArray( const void *array, size_t num, size_t size, int (*comp)(const void *, const void *) );
 115: bool    IsValidArgcArgv( int argc, char **argv );
 116: bool    IsValidCodePtr( void *fn );
 117: bool    IsValidCommandLineString( const char *string );
 118: bool    IsValidDate( int year, int month, int day );
 119: bool    IsValidFilePtr( FILE *fp );
 120: bool    IsValidLengthStringPtr( const char *str, size_t length );
 121: bool    IsValidLocalPathString( const char *path );
 122: bool    IsValidLocalPathMaskString( const char *mask );
 123: bool    IsValidPtr( void *ptr, size_t uSize );
 124: bool    IsValidReadPtr( const void *ptr, size_t uSize );
 125: bool    IsValidStringBufferPtr( char *ptr, size_t count );
 126: bool    IsValidStringPtr( const char *str );
 127: bool    IsValidWritePtr( void *ptr, size_t uSize );
 128: 
 129: // j
 130: int     jmscode( const char *p );
 131: bool    jmsmatch( const char *ptn, const char *str ); // 不要?
 132: char   *jmsnext( const char *p );
 133: char   *jmschr( const char *string, int c );
 134: char   *jmsrchr( const char *string, int c );
 135: //int   jmscmpi( const char *str1, const char *str2 );
 136: char   *jmsstr( const char *target, const char *pattern );
 137: char   *jmspbrk( const char *base, const char *ctrl );
 138: size_t  jmscspn( const char *base, const char *ctrl );
 139: size_t  jmsspn(  const char *base, const char *ctrl );
 140: 
 141: // k
 142: // l
 143: // m
 144: bool    MakeFullPath( char *fullpath, size_t bufsize, const char *path, const char *filename );
 145: size_t  memcspn( const void *base, size_t length, const char *ctrl, size_t count );
 146: void   *memdup( const void *base, size_t size );
 147: bool    memeql( const void *p, const void *q, size_t size );
 148: void    memlrotate( void *array, size_t shift, size_t num, size_t size );
 149: void   *memmem( const void *target, size_t length, const void *pattern, size_t ptnlen );
 150: void   *mempbrk( const void *base, size_t length, const char *ctrl, size_t count );
 151: void   *memreverse( void *array, size_t num, size_t size );
 152: void    memrrotate( void *array, size_t shift, size_t num, size_t size );
 153: size_t  memspn( const void *base, size_t length, const char *ctrl, size_t count );
 154: void    memswap( void *va, void *vb, size_t size );
 155: void   *memzero( void *p, size_t size );
 156: 
 157: // n
 158: // o
 159: // p
 160: //int     pathcmp( const char *path1, const char *path2 );
 161: //int     pathncmp( const char *path1, const char *path2, size_t count );
 162: //bool    patheql( const char *path1, const char *path2 );
 163: //bool    pathneql( const char *path1, const char *path2, size_t count );
 164: 
 165: // q
 166: // r
 167: // s
 168: int     strcode( const char *string );
 169: //int     strncode( const char *string, size_t count );
 170: char   *strnext( const char *string );
 171: //char   *strnnext( const char *string, size_t count );
 172: //char   *strprev( const char *string );
 173: size_t  strputc( char *buffer, size_t bufsize, size_t offset, int c );
 174: size_t  strputs( char *buffer, size_t bufsize, size_t offset, const char *string );
 175: size_t  strnputs( char *buffer, size_t bufsize, size_t offset, const char *string, size_t count );
 176: char   *StrAlloc( const char *string );
 177: int     strchop( char *string );
 178: char   *strchri( const char *string, int c );
 179: void    strcopy( char *buffer, size_t bufsize, const char *string );
 180: void    strncopy( char *buffer, size_t bufsize, const char *string, size_t count );
 181: int     strcount( const char *string1, const char *string2 );
 182: //int   strncount( const char *string1, const char *string2, size_t count );
 183: bool    streql( const char *str1, const char *str2 );
 184: bool    streqli( const char *str1, const char *str2 );
 185: bool    strhstr( const char *target, const char *pattern );
 186: bool    strhstri( const char *target, const char *pattern );
 187: void    StrLower( char *str );
 188: bool    strmatch( const char *ptn, const char *str );
 189: //bool  strnmatch( const char *str, const char *ptn, int count );
 190: char   *strmove( char *buf, const char *str );
 191: char   *strnchr( const char *string, int c, size_t n );
 192: char   *strnchri( const char *string, int c, size_t n );
 193: size_t  strncspn( const char *base, const char *ctrl, size_t count );
 194: char   *strndup( const char *string, size_t count );
 195: bool    strneql( const char *str1, const char *str2, size_t count );
 196: bool    strneqli( const char *str1, const char *str2, size_t count );
 197: size_t  strnlen( const char *string, size_t count );
 198: char   *strnpbrk( const char *base, const char *ctrl, size_t count );
 199: char   *strnrchr( const char *string, int c, size_t n );
 200: char   *strnrchri( const char *string, int c, size_t n );
 201: char   *strnrstr( const char *string, const char *pattern, size_t count );
 202: char   *strnrstri( const char *string, const char *pattern, size_t count );
 203: size_t  strnspn(  const char *base, const char *ctrl, size_t count );
 204: char   *strnstr( const char *string, const char *pattern, size_t count );
 205: char   *strnstri( const char *string, const char *pattern, size_t count );
 206: char   *strntail( const char *string, size_t count );
 207: char   *strrchri( const char *string, int c );
 208: char   *strrep( char *string, const char *From, const char *To );
 209: //char *strnrep( char *string, const char *From, const char *To, size_t count );
 210: char   *strrevj( char *str );
 211: char   *strrstr( const char *string, const char *pattern );
 212: char   *strrstri( const char *string, const char *pattern );
 213: char   *strshift( char *string, ptrdiff_t shift );
 214: char   *strskip( const char *string, const char *skip );
 215: //char   *strnskip( const char *string, const char *skip, size_t count );
 216: char   *strstri( const char *string, const char *pattern );
 217: char   *strsub( char *buffer, size_t bufsize, const char *p, const char *q );
 218: char   *strtail( const char *string );
 219: char   *strtstr(  const char *target, const char *pattern );
 220: char   *strtstri( const char *target, const char *pattern );
 221: void    StrUpper( char *str );
 222: char   *SwapFileExtension( char *path, size_t bufsize, const char *ext );
 223: 
 224: // t
 225: // u
 226: size_t  unique( void *array, size_t num, size_t size, int (*comp)(const void *, const void *) );
 227: 
 228: // v
 229: // w
 230: // x
 231: // y
 232: // z
 233: 
 234: 
 235: #ifdef __cplusplus
 236: } // extern "C"
 237: #endif
 238: 
 239: 
 240: #endif // #ifndef TOOLBASE_HEAD_INCLUDED
 241: 
 242: 
 243: //** end **
 244: 

参照: argcargv.cpp, lnkctrl.cpp, picker.cpp, browsbox.cpp, dyndlg.cpp, curfile.cpp, icofile.cpp, toolmci.cpp, crc16.cpp, crc32.cpp, md4.cpp, md5.cpp, pathargv.cpp, sha1.cpp, sha256.cpp, sha512.cpp, toolnext.cpp, toolold.cpp, snprintf.cpp, susie.cpp, toolbase.cpp, toolctrl.cpp, toolptrc.cpp, tools.h, toolsys.cpp, toolsysx.cpp, toolwind.cpp, workthrd.cpp


Google
ご意見・ご感想をお聞かせ下さい。匿名で送信できます。

 * 返信が必要な場合には postmaster@katsura-kotonoha.sakura.ne.jp へ直接メールしてください。

水無瀬の部屋 > sample > tools > header > toolbase.h

このページは cpp2web が出力しました。
水無瀬 優 postmaster@katsura-kotonoha.sakura.ne.jp
http://katsura-kotonoha.sakura.ne.jp/prog/code/tools/header/toolbase_h.shtml
『新妻LOVELY×CATION』を応援しています!